package org.mystock.candlestick.model;

import java.util.Date;

@SuppressWarnings("serial")
public class DailyData extends PersistentEntity {

	private Ticker ticker;

	private float open;
	private float close;
	private float high;
	private float low;
	private Date dataDate;
	private long volume;

	// computed fields
	float upperShadow;
	float lowerShadow;
	float range;
	float body;

	/**
	 * @return the ticker
	 */
	public Ticker getTicker() {
		return ticker;
	}

	/**
	 * @param ticker
	 *            the ticker to set
	 */
	public void setTicker(Ticker ticker) {
		this.ticker = ticker;
	}

	/**
	 * @return the open
	 */
	public float getOpen() {
		return open;
	}

	/**
	 * @param open
	 *            the open to set
	 */
	public void setOpen(float open) {
		this.open = open;
	}

	/**
	 * @return the close
	 */
	public float getClose() {
		return close;
	}

	/**
	 * @param close
	 *            the close to set
	 */
	public void setClose(float close) {
		this.close = close;
	}

	/**
	 * @return the high
	 */
	public float getHigh() {
		return high;
	}

	/**
	 * @param high
	 *            the high to set
	 */
	public void setHigh(float high) {
		this.high = high;
	}

	/**
	 * @return the low
	 */
	public float getLow() {
		return low;
	}

	/**
	 * @param low
	 *            the low to set
	 */
	public void setLow(float low) {
		this.low = low;
	}

	/**
	 * @return the dataDate
	 */
	public Date getDataDate() {
		return dataDate;
	}

	/**
	 * @param dataDate the dataDate to set
	 */
	public void setDataDate(Date dataDate) {
		this.dataDate = dataDate;
	}

	/**
	 * @return the volume
	 */
	public long getVolume() {
		return volume;
	}

	/**
	 * @param volume
	 *            the volume to set
	 */
	public void setVolume(long volume) {
		this.volume = volume;
	}

	public float getBody() {
		return open - close;
	}
	
	public float getRange() {
		return high - low;
	}
	
	public float getUpperShadow() {
		return high - open;
	}

	public float getLowerShadow() {
		return close - low;
	}
	
	public float getUpperShadowPercentWRTRange() {
		return (getUpperShadow() / getRange()) * 100;
	}

	public float getUpperShadowPercentWRTBody() {
		return Math.abs((getUpperShadow() / getBody()) * 100);
	}
	
	public float getLowerShadowPercentWRTRange() {
		return (getLowerShadow() / getRange()) * 100;
	}

	public float getLowerShadowPercentWRTBody() {
		return Math.abs((getLowerShadow() / getBody()) * 100);
	}

}
